import { defineStore } from 'pinia'
import { set } from 'vue-demi'

export const storage = defineStore({
  id: 'counter',
  state: () => ({
    counter: 0,
    newSonglanguageType:0,
    LanguageList : [
      {
        value: '0',
        name: '全部'
      },
      {
        value: '7',
        name: '华语'
      },
      {
        value: '96',
        name: '欧美'
      },
      {
        value: '8',
        name: '日本'
      },
      {
        value: '16',
        name: '韩国'
      }
    ],
    languageSingerList : [
      {
        name:'全部',
        value:-1,
      },
      {
        name:'华语',
        value:7,
      },
      {
        name:'欧美',
        value:96,
      },
      {
        name:'日本',
        value:8,
      },
      {
        name:'韩国',
        value:16,
      },
      {
        name:'其他',
        value:0,
      }
    ],
    classifyList:[
      {
        name:"全部",
        value:-1,
      },{
        name:'男歌手',
        value:1
      },{
        name:'女歌手',
        value:2
      },{
        name:'乐队组合',
        value:3
      }
    ],
    // newSongsList:[],
    tagsArr:[],
    songListId:null,//分类的歌单Id
    // songListContent:[],
    rankingSongData:[],

    songPlayList : [], //选择播放的歌单
    audioMes:{},//当前播放歌曲信息 id,name,songUrl,picUrl
    albumName:'',//专辑名字，只在显示评论时有用
    isImmediatelyPlay:false,

    singerList:[],//歌手名单
    singerParam :{},//请求歌手名单的参数
    singerId:{},//歌手主页歌手Id
    mvId:null,//当前播放的mv信息  只接收一个id
    
    searchKeyword:'',
    // searchSongs:[]//搜索得来的单曲
    searchType:null,
    albumId:null,
    isShowComment:false, //评论的开闭
    commentsType:0,
    commentId:null,
    isPlayAll:false,
    color:'rgb(192, 192, 192)',

  }),
  getters: {
    doubleCount: (state) => state.counter * 2
    
  },
  actions: {
    increment() {
      this.counter++
    },
    changeNewSonglanguageType(num){
      this.newSonglanguageType = num
    },
    setSongListId(id){
      this.songListId = id
    },
    setTagArr(arr){
      this.tagsArr = arr
    },
    setSongListContent(arr){
      this.songListContent = arr
    },
    setRankingSongData(arr){
      this.rankingSongData = arr
    },
    addSongPlayList(id,name,songUrl,picUrl){
      for (let i = 0; i < this.songPlayList.length; i++) {
        if (id === this.songPlayList[i].id) 
          this.SongPlayListDelete(id)
      }
      this.songPlayList.push({id,name,songUrl,picUrl})
    },
    SongPlayListDelete(id){
      for (let i = 0; i < this.songPlayList.length; i++) {
        if (id === this.songPlayList[i].id)
          this.songPlayList.splice(i,1)
      }
    },
    clearSongPlayList(){
      this.songPlayList = []
    },

    setAudioMes(id,name,songUrl,picUrl){
      this.audioMes = {id,name,songUrl,picUrl}
    },
    changeIsImmediatelyPlay(){
      this.isImmediatelyPlay = !this.isImmediatelyPlay
    },


    setSingerList(arr){
      this.singerList  = arr
    },
    setSingerParam(obj){
      this.singerParam = obj
    },
    setSingerId(id){
      this.singerId = id
    },
    setMVId(id){
      this.mvId = id
    },
    setSearchKeyword(str){
      this.searchKeyword = str
    },
    setSearchType(number){
      this.searchType = number
    },
    setAlbumId(number){
      this.albumId = number
    },

    changeIsShowComment(){
      this.isShowComment = !this.isShowComment
    },
    setCommentsType(num){
      this.commentsType = num
    },
    setCommentId(id){
      this.commentId = id
    },
    setAlbumName(str){
      this.albumName = str
    },
    setIsPlayAll(bool){
      this.isPlayAll= bool
    },
    setColor(str){
      this.color = str
    },
  }
})
